package cn.zcscloud.mall.mbg.mapper;

import cn.zcscloud.mall.mbg.model.UmsMenu;
import cn.zcscloud.mall.mbg.model.UmsMenuExample;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface UmsMenuMapper extends BaseMapper<UmsMenu> {

    long countByExample(UmsMenuExample example);

    int deleteByExample(UmsMenuExample example);

    int deleteByPrimaryKey(Long id);

    int insert(UmsMenu record);

    int insertSelective(UmsMenu record);

    List<UmsMenu> selectByExample(UmsMenuExample example);

    UmsMenu selectByPrimaryKey(Long id);

    int updateByExampleSelective(@Param("record") UmsMenu record, @Param("example") UmsMenuExample example);

    int updateByExample(@Param("record") UmsMenu record, @Param("example") UmsMenuExample example);

    int updateByPrimaryKeySelective(UmsMenu record);

    int updateByPrimaryKey(UmsMenu record);

    @Select("select * from ums_menu where id in\n" +
            "         (select menu_id from ums_role_menu_relation where\n" +
            "          role_id = (select role_id from ums_admin_role_relation where admin_id = #{userId}))")
    List<UmsMenu> findByUserId(@Param("userId") Long userId);
}